"""收藏模型"""
from sqlalchemy import Column, Integer, ForeignKey, UniqueConstraint
from .base import BaseModel


class Favorite(BaseModel):
    """收藏表模型"""
    __tablename__ = "favorites"
    
    user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
    video_id = Column(Integer, ForeignKey("videos.id"), nullable=False)
    
    # 确保用户对同一视频只能收藏一次
    __table_args__ = (
        UniqueConstraint('user_id', 'video_id', name='_user_video_favorite_uc'),
    )
